﻿@using TD.Common.Kendo.Mvc5.Grid
@using TD.CTS.Data.Entities

@model Schedule
@(Html.Kendo().Grid<ScheduleEmployee>()
                             .Init("EmployeeGrid")
                                      .Editable()
                                      .Reorderable(conf => conf.Columns(false))
                                      .Columns(columns =>
                                      {
                                          columns.Buttons(buttons =>
                                          {
                                              buttons.Edit();
                                              buttons.Delete();

                                          }).Width(80);
                                          //columns.Bound(e => e.SystemRoleCode).Width(100).Title("Код роли");
                                          columns.ForeignKey(e => e.SystemRoleCode, (System.Collections.IEnumerable)ViewBag.SystemRoles, "Code", "Name").Width(300).Title("Роль").Sortable(false);
                                          columns.ForeignKey(e => e.SystemLogin, (System.Collections.IEnumerable)ViewBag.Users, "Login", "FullName").Width(250).Title("Сотрудник").Sortable(false).EditorTemplateName("GridNullableForeignKey");
                                          //columns.Bound(e => e.SystemLogin).Width(100).Title("Сотрудник");
                                          columns.Template(e => { }).ClientTemplate(" ").Width("100%").HtmlAttributes(new { @class = "k-group-cell" });
                                      })
                                      .DataSource(dataSource => dataSource
                                          .Ajax()
                                          .PageSize(20)
                                          .Model(model =>
                                          {
                                              model.Id(e => e.ScheduleID); //(e => e.Id);
                                              model.Id(e => e.SystemRoleCode);
                                              model.Field(e => e.SystemRoleCode).Editable(false);

                                          })
                                           .Read(read => read.Action("GetScheduleEmployees", "Schedules", new { ScheduleID = Model.Id })/*.Data("EmployeesGetDataRead")*/)
                                           .Update(update => update.Action("UpdateScheduleEmployee", "Schedules"))
                                           .Destroy(destroy => destroy.Action("DeleteScheduleEmployee", "Schedules"))
                                           .Events(events => events.Error("kendo_grid_error_handler").RequestEnd("EmployeesRequestEnd"))
                                      )
                                          .Events(events => events.Edit("kendo_grid_onrowedit").DataBound("OnEmployeeGridDataBound"))
)
                     
<script>

   

  

    

</script>